@extends('admin.layouts.content')
@section('script')
<script>
    new Wanyue().layuiAdmin.list({
        search: [{
            type: 'text', title: '用户名', name: 'like[username]'
        }]
        , actions: [{
            title: '添加用户'
            , btn: 'layui-btn-normal'
            , handler: function(self, data) {
                self.open({
                    title: '添加用户'
                    , offset: '120px'
                    , area: ['60%', '60%']
                    , url: '{{ url("admin/admin/create") }}'
                });
            }
        }]
    }, {
        url: '{{ url()->current() }}'
        , fields: [
            {field:'id', title:'用户编号', fixed: 'left', width:100}
            , {field: 'email', title: '登录用户名', width: 200}
            , {field: 'name', title: '名称', width: 100}
            , {field: 'mobile', title: '手机号码', width: 140}
            , {field: 'created_at', title: '创建时间', width: 160}
        ]
        , csrf: {name: '_token', value: '{!! csrf_token() !!}'}
        , toolbars: {
            width: 100
            , list: [{
                title: '编辑'
                , btn: 'layui-btn-normal'
                , icon: 'layui-icon-edit'
                , handler: function(open, data) {
                    open({
                        type: 'open'
                        , offset: '120px'
                        , area: ['60%', '60%']
                        , title: '编辑'
                        , url: '{{ url("admin/admin/update", ["id" => "__ID__"]) }}'.replace('__ID__', data.id)
                    });
                }
            }, {
                title: '分配角色'
                , btn: 'layui-btn-warm'
                , icon: 'layui-icon-set'
                , handler: function(open, data) {
                    open({
                        type: 'open'
                        , title: '分配角色'
                        , url: '{{ url("admin/admin/relate", ["id" => "__ID__"]) }}'.replace('__ID__', data.id)
                    });
                }
            }, {
                title: '删除'
                , btn: 'layui-btn-danger'
                , icon: 'layui-icon-delete'
                , handler: function(open, data) {
                    open({
                        type: 'confirm'
                        , del: true
                        , title: '删除'
                        , url: '{{ url("admin/admin/destroy", ["id" => "__ID__"]) }}'.replace('__ID__', data.id)
                    });
                }
            }]
        }
    });
</script>
@endsection
